var ajax = require('../../utils/ajax.js');
var app = getApp();

Page({
    data: {
        dataLoaded: true,
        orderList: [],
        userInfo: {},
        winHei: 0
    },

    onLoad() {
        var _self = this;

        this._getOrderList();

        app.getUserInfo(function(userInfo) {
            _self.setData({
                userInfo
            });
        });
        wx.getSystemInfo({
            success: function(res) {
                _self.setData({
                	winHei:res.windowHeight
                })
            }
        })
    },

    _back() {
        wx.switchTab({
            url: '/pages/mine/mine'
        });
    },

    _getOrderList() {
        var _self = this;

        ajax.G('/openapi/User/userOrder', {}, function(d) {

            if (d.code == 0) {

                _self.setData({
                    orderList: d.result
                });

            } else {
                if (d.msg) {
                    util.alert(d.msg);
                }
            }

        });
    }
});